package com.student.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Profession entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "Profession", schema = "dbo", catalog = "StudentManager")
public class Profession implements java.io.Serializable {

	// Fields

	private Long professionId;
	private College college;
	private String professionName;
	private String professionAlias;
	private String professionSimpleName;
	private String professionCode;
	private Set<Dorm> dorms = new HashSet<Dorm>(0);
	private Set<ClassInfo> classInfos = new HashSet<ClassInfo>(0);

	// Constructors

	/** default constructor */
	public Profession() {
	}

	/** minimal constructor */
	public Profession(Long professionId, String professionName) {
		this.professionId = professionId;
		this.professionName = professionName;
	}

	/** full constructor */
	public Profession(Long professionId, College college,
			String professionName, String professionAlias,
			String professionSimpleName, String professionCode,
			Set<Dorm> dorms, Set<ClassInfo> classInfos) {
		this.professionId = professionId;
		this.college = college;
		this.professionName = professionName;
		this.professionAlias = professionAlias;
		this.professionSimpleName = professionSimpleName;
		this.professionCode = professionCode;
		this.dorms = dorms;
		this.classInfos = classInfos;
	}

	// Property accessors
	@Id
	@Column(name = "Profession_id", unique = true, nullable = false, precision = 18, scale = 0)
	@GeneratedValue
	public Long getProfessionId() {
		return this.professionId;
	}

	public void setProfessionId(Long professionId) {
		this.professionId = professionId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "College_id")
	public College getCollege() {
		return this.college;
	}

	public void setCollege(College college) {
		this.college = college;
	}

	@Column(name = "Profession_Name", nullable = false, length = 40)
	public String getProfessionName() {
		if(this.professionName==null){
			this.professionName=this.professionSimpleName;
		}
		return this.professionName;
	}

	public void setProfessionName(String professionName) {
		this.professionName = professionName;
	}

	@Column(name = "Profession_Alias", length = 20)
	public String getProfessionAlias() {
		return this.professionAlias;
	}

	public void setProfessionAlias(String professionAlias) {
		this.professionAlias = professionAlias;
	}

	@Column(name = "Profession_Simple_Name", length = 20)
	public String getProfessionSimpleName() {
		if(this.professionSimpleName==null){
			this.professionSimpleName=this.professionName;
		}
		return this.professionSimpleName;
	}

	public void setProfessionSimpleName(String professionSimpleName) {
		this.professionSimpleName = professionSimpleName;
	}

	@Column(name = "Profession_Code", length = 40)
	public String getProfessionCode() {
		return this.professionCode;
	}

	public void setProfessionCode(String professionCode) {
		this.professionCode = professionCode;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "profession")
	public Set<Dorm> getDorms() {
		return this.dorms;
	}

	public void setDorms(Set<Dorm> dorms) {
		this.dorms = dorms;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "profession")
	public Set<ClassInfo> getClassInfos() {
		return this.classInfos;
	}

	public void setClassInfos(Set<ClassInfo> classInfos) {
		this.classInfos = classInfos;
	}

}